const router = require("koa-router")()
const MovieModel = require("../../models/movie")
router.get("/api/movie",async ctx=>{
    var {m} = ctx.query
    try{
        var data = await MovieModel(m).find({}).sort({rating:-1})
        if(data.length){
            ctx.body={
                code:200,
                result:data,
                msg:m
            }
        }else{
            throw new Errow("输入的参数不合法")
        }
    }catch(err){
        ctx.body={
            code:400,
            msg:"请求参数不合法"
        }
    }
})
module.exports = router